﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Validity.Rules;
using Validity.Rules.Decorators;

namespace Validity.Test.Rules.Decorators
{
  [TestClass]
  public class CustomComparisonRuleDecoratorTest
  {
    private readonly Mock<IComparisonRule<ObjectStub, IComparable>> _baseRule;
    private readonly ObjectStub _objectStub = new ObjectStub();

    public CustomComparisonRuleDecoratorTest()
    {
      _baseRule = new Mock<IComparisonRule<ObjectStub, IComparable>>(MockBehavior.Strict);
    }

    [TestMethod]
    public void TestIsViolatedByDelegated()
    {
      var comparison = new Comparison<IComparable>((lhs, rhs) => 0);
      var rule = new CustomComparisonRuleDecorator<ObjectStub, IComparable>(_baseRule.Object, comparison);

      _baseRule.Setup(mock => mock.IsViolatedBy(_objectStub, "string", comparison)).Returns(false);

      Assert.IsFalse(rule.IsViolatedBy(_objectStub, "string"));
    }
  }
}
